/*
 * $Id: PrcCodeConstants.java,v 1.18 2009/11/02 22:25:02 navdeep_mahajan Exp $
 * 
 * Copyright (C) 2008 General Electric Company. All Rights Reserved.
 * 
 * This software is the confidential and proprietary information of the General
 * Electric Company (GE). You shall not disclose this software and shall use it
 * only in accordance with the terms of the license agreement you entered into
 * with GE.
 * 
 * GE MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
 * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
 * NON-INFRINGEMENT. GE SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
 * AS A RESULT OF USING, MODIFYING, OR DISTRIBUTING THIS SOFTWARE OR ITS
 * DERIVATIVES.
 */
package com.ge.healthcare.autosc.processor;

import com.ge.healthcare.autosc.common.exceptions.BasicException;
import com.ge.healthcare.autosc.common.util.CommonCodeConstants;

/**
 * 
 * @author 212042946
 *
 */
public class PrcCodeConstants {

	/* General application error */
	public static final String PRC_F_APP_000 = "PRC_F_APP_000";
	/* Failed to dispatch the task the task handler error */
	public static final String PRC_F_APP_001 = "PRC_F_APP_001";
	/* Mail notification delivery error */
	public static final String PRC_F_APP_002 = "PRC_F_APP_002";
	/* JMS delivery error */
	public static final String PRC_F_APP_003 = "PRC_F_APP_003";
	/* Failed finding request for task */
	public static final String PRC_F_APP_004 = "PRC_F_APP_004";
	/* Process server failure might have left the message */
	public static final String PRC_F_APP_005 = "PRC_F_APP_005";
	/* Unknown system error */
	public static final String PRC_F_SYS_000 = "PRC_F_SYS_000";
	/* Successful code */
	public static final String PRC_S_APP_000 = "PRC_S_APP_000";
	/* Retry Code */
	public static final String PRC_R_APP_000 = "PRC_R_APP_000";
	/* In process */
	public static final String PRC_P_APP_000 = "PRC_P_APP_000";
	/* OnWatch task is submitted */
	public static final String PRC_P_APP_001 = CommonCodeConstants.TASK_SAVED_ONWATCH_QUEUE;
	
	// START SHEMJOB CODE
	/* Failed loading guidance*/
	public static final String PRC_F_SHM_001 = "PRC_F_SHM_001";
	/* Failed finding request for task */
	public static final String PRC_F_SHM_002 = "PRC_F_SHM_002";
	/* Failed creating file data set */
	public static final String PRC_F_SHM_003 = "PRC_F_SHM_003";
	/* Failed setting up magnet monitor processor */
	public static final String PRC_F_SHM_004 = "PRC_F_SHM_004";
	/* Failed processing request data set */
	public static final String PRC_F_SHM_005 = "PRC_F_SHM_005";
	/* Failed processing event */
	public static final String PRC_F_SHM_006 = "PRC_F_SHM_006";
	/* Error reading from data source because IOException */
	public static final String PRC_F_SHM_007 = "PRC_F_SHM_007";
	/* Record reader not open */
	public static final String PRC_F_SHM_008 = "PRC_F_SHM_008";
	/* Magnet Monitor format is not correct */
	public static final String PRC_F_SHM_009 = "PRC_F_SHM_009";
	/* XML parser is not defined */
	public static final String PRC_F_SHM_010 = "PRC_F_SHM_010";
	/* System is not found in PPADS sites */
	public static final String PRC_F_SHM_011 = "PRC_F_SHM_011";
	/* Cannot find guidance for given data source */
	public static final String PRC_F_SHM_012 = "PRC_F_SHM_012";
	/* No processing defined for given function */
	public static final String PRC_F_SHM_013 = "PRC_F_SHM_013";
	/* PPADS sites directory do not exist */
	public static final String PRC_F_SHM_014 = "PRC_F_SHM_014";
	/* Internal Error. Incorrect use of class, please contact AutoSC support team */
	public static final String PRC_F_SHM_015 = "PRC_F_SHM_015";
	/* Guidance file does not exist */
	public static final String PRC_F_SHM_016 = "PRC_F_SHM_016";
	/* Failed parsing guidance file with XML parser */
	public static final String PRC_F_SHM_017 = "PRC_F_SHM_017";
	/* Failed loading guidance from guidance file */
	public static final String PRC_F_SHM_018 = "PRC_F_SHM_018";
	// STOP SHEMJOB CODE

	// START PRODIAGS SCHEDULE CODE
	/* Prodiags schedule task does fulfill required parameter requirement */
	public static final String PRC_F_PRD_001 = "PRC_F_PRD_001";
	/* Unable to validate parameters of given prodiags task */
	public static final String PRC_F_PRD_002 = "PRC_F_PRD_002";
	// END PRODIAGS SCHEDULE CODE
	
	/**
	 * Check if the given exception has error code.If not, use default
	 */
	public static String getCode(BasicException be, String defaultCode) {
		String code;
		if(be.getErrorCode() != null) {
			code = be.getErrorCode();
		} else {
			code = defaultCode;
		}
		return code;
	}
}
